package com.hdcx.Minfresh.adapter;


import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hdcx.Minfresh.R;
import com.hdcx.Minfresh.bean.MegWrapper;
import com.hdcx.Minfresh.holder.MainHolder;

/**
 * Created by Administrator on 2016/11/9.
 */

public class MineMsgAdapter extends RecyclerView.Adapter<MineMsgAdapter.Holder> {
    FragmentActivity mActivity;
    MegWrapper data;

    public MineMsgAdapter(FragmentActivity mActivity) {
        this.mActivity = mActivity;
    }

    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view;
        LayoutInflater layoutInflater = LayoutInflater.from(mActivity);
            view = layoutInflater.inflate(R.layout.item_fragment_point_two, parent, false);
        return new Holder(view);
    }

    @Override
    public void onBindViewHolder(Holder holder, int position) {
          holder.tv_point.setText("");
          holder.tv_content.setText(data.getList().get(position).getInfo());
          holder.tv_time.setText(data.getList().get(position).getAdd_time());
    }

    @Override
    public int getItemCount() {
        if(data==null||data.getList()==null){
            return 0;
        }
        return data.getList().size();
    }

    public void setData(MegWrapper response) {
        data = response;
        notifyDataSetChanged();
    }


    public  class Holder extends RecyclerView.ViewHolder{
        public TextView tv_point,tv_content,tv_time;
        public Holder(View itemView) {
            super(itemView);
            tv_point = (TextView) itemView.findViewById(R.id.tv_point);
            tv_content = (TextView) itemView.findViewById(R.id.tv_content);
            tv_time = (TextView) itemView.findViewById(R.id.tv_time);
        }
    }
}
